﻿<!DOCTYPE html>
<html>
<head>
<!----------------------------------------------------------

	Copyright (c) 2017-2018 Jean-Marc VIGLINO,
	released under CeCILL-B (french BSD like) licence: http://www.cecill.info/

------------------------------------------------------------>
	<title>ol-ext: Search Parcelle control</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

	<meta name="description" content="Control to add a grid reference to a map." />
	<meta name="keywords" content="ol3, control, search, BAN, french, places, autocomplete" />

	<!-- FontAwesome -->
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

	<!-- jQuery -->
	<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.min.js"></script>
	<!-- IE 9 bug on ajax tranport  -->
	<!--[if lte IE 9]>
	<script type='text/javascript' src='//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js'></script>
	<![endif]-->

	<!-- Openlayers -->
	<link rel="stylesheet" href="https://openlayers.org/en/latest/css/ol.css" />
	<script type="text/javascript" src="https://openlayers.org/en/latest/build/ol.js"></script>
	<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL,Object.assign"></script>
	
	<!-- ol-ext -->
	<link rel="stylesheet" href="../../dist/ol-ext.css" />
	<script type="text/javascript" src="../../dist/ol-ext.js"></script>

	<script type="text/javascript" src="https://cdn.rawgit.com/Viglino/Geoportail-KISS/gh-pages/apikey.js"></script>
	
	<link rel="stylesheet" href="../style.css"/>
	<style>
		.ol-search ul {
			color: #333;
			font-size:0.85em;
			max-width: 21em;
		}
		.ol-search ul i {
			display: block;
			color: #333;
			font-size:0.85em;
		}
		.info a img {
			display: inline-block;
			height: 100px;
			max-width: 150px;
			margin: .5em;
		}
	</style>
</head>
<body >
	<a href="https://github.com/Viglino/ol-ext" class="icss-github-corner"><i></i></a>

	<a href="../../index.html">
		<h1>ol-ext: Search Parcelle control</h1>
	</a>

	<div class="info">
		<i>ol.control.SearchGeoportailParcelle</i> is a control to search French parcelle using the 
		<a href="https://geoservices.ign.fr/documentation/geoservices/geocodage.html">Geoportail API</a>.
		<div style="text-align: center">
			<b>In partnership with:</b><br/>
			<a href="https://www.geoportail.gouv.fr/"><img src="https://www.geoportail.gouv.fr/assets/images/logo-geoportail.svg" alt="Geoportail"></a>
			<a href="http://ign.fr"><img src="https://upload.wikimedia.org/wikipedia/fr/thumb/a/a0/IGN_logo_2012.svg/545px-IGN_logo_2012.svg.png" alt="IGN" class="jsx-3503728609 logo"></a>
		</div>	
		<ul>
      <li>
        You need an API key (<a href="http://professionnels.ign.fr/ign/contrats">get a key</a> 
        see <a href="https://geoservices.ign.fr/documentation/services-acces.html">documentation page</a>).
      </li>
      <li>Start cherching a french commune (Paris, Nice, Dijon...)</li>
      <li>Use a wildcard symbol (<b>*</b>) to specify any part of the parcelle number, ie. <b>section=a*</b> to search for AB, AC, AD, etc. sections.</li>
		</ul>
		<br/>
		<i>ol.control.SearchGeoportailParcelle</i> use the <a href="map.control.searchgeoportail.html">ol.control.SearchGeoportail</a> control.
	</div>

	<!-- DIV pour la carte -->
	<div id="map" style="width:600px; height:400px;"></div>

	<div class="options">
		<i>Use the search control to start a new search.</i>
	</div>
	
	<script type="text/javascript">
  // Layers
  var layers = [ new ol.layer.Tile({ source: new ol.source.OSM() }) ];

  // The map
  var map = new ol.Map ({
    target: 'map',
    view: new ol.View ({
      zoom: 5,
      center: [166326, 5992663]
    }),
    interactions: ol.interaction.defaults({ altShiftDragRotate:false, pinchRotate:false }),
    layers: layers
  });

  // Set the control grid reference
  var search = new ol.control.SearchGeoportailParcelle ({
    apiKey: apiKey,
    position: true	// Search, with priority to geo position
  });
  map.addControl (search);

  // Select feature when click on the reference index
  search.on('parcelle', function(e) {
    console.log(e);
    map.getView().animate({
      center:e.coordinate,
      zoom: Math.max (map.getView().getZoom(),16)
    });
  });

	</script>
	
</body>
</html>